package com.example.smartcity_poverty.ui.AllService.OA.adapter

import android.content.Intent
import com.example.smartcity_poverty.App.Companion.url
import com.example.smartcity_poverty.Base.BaseRecyclerAdapter
import com.example.smartcity_poverty.logic.ServiceBean.OA.OaDataListModel
import com.example.smartcity_poverty.logic.util.Util.glide
import com.example.smartcity_poverty.ui.AllService.OA.activity.OaShowDataListActivity
import kotlinx.android.synthetic.main.re_oa_home_list.*

/**
 *  created by ikun
 *  ANDROID STUDIO - version 4.0
 *  email: jinkunwei41@gmail.com
 * --------------------------------
 *  门诊预约主页列表适配器
 **/
class OaHomeListAdapter (
    val list: MutableList<OaDataListModel.RowsBean>,
    layoutId: Int
): BaseRecyclerAdapter<OaDataListModel.RowsBean>(list, layoutId){
    override fun setData(
        view: BaseViewHolder.ViewFind,
        data: OaDataListModel.RowsBean,
        position: Int,
        holder: BaseViewHolder
    ) {
        val d = list[position]
        val fv = holder.viewFind
        val con = holder.viewFind.view?.context

        // 填充数据
        glide(url + d.imgUrl, fv.oaHImage)
        fv.oaHName.text = d.hospitalName
        fv.oaHXin.rating = d.level.toFloat()

        holder.itemView.setOnClickListener {
            con?.startActivity(Intent(con, OaShowDataListActivity::class.java).putExtra("id", d.id.toString()))
        }
    }
}